#!/bin/bash
# This is a ShellScript For Auto DB Backup and Delete old Backup
#
backupdir=/usr/local/backup
mkdir -p $backupdir
db_name=huiyou
time=`date +%Y%m%d%H%M`
mysqldump -u 'root' -p'5x11W^J!oVKc7H^I' $db_name| gzip > $backupdir/$db_name$time.sql.gz
find $backupdir -name $db_name"*.sql.gz" -type f -mtime +7 -exec rm {} \; > /dev/null 2>&1
